package day5.string;

import org.junit.Test;

import java.util.Arrays;

/**
 * @author joker
 * @date 2022/4/15 0015 - 19:35
 */
public class StringTest3 {
    public static void main(String[] args) {
        char a1='a';
        char a2='A';
        int a3=a1+10;
        char a4=97;
        System.out.println(a1);
        System.out.println(a2);
        System.out.println(a3);
        System.out.println(a4);
        System.out.println(a1+a2);
    }
    //char-->string
    @Test
    public void test1(){
        char[] ch={'h','e','l','l','o'};
        String str=new String(ch);
        String str2="hello";
        System.out.println(str);
        System.out.println(str.equals(ch));
        System.out.println(str2.equals(ch));
    }
    @Test
    public void test2(){
        int str1='a'+'b'+'c';
        String str2 ="a"+"b"+"c";
        String str3="abc";
        System.out.println(str2==str3);
        System.out.println(str1);

    }
    //string-->char
    @Test
    public void test3(){
        String  str="hello";
        char[] ch=str.toCharArray();
        System.out.println(Arrays.toString(ch));
    }
    //string-->byte
    @Test
    public void test4(){
        String str="hello";
        byte[] bytes = str.getBytes();
        System.out.println(Arrays.toString(bytes));
    }
    //byte-->string
    @Test
    public void test5(){
        byte[] bytes={104, 101, 108, 108, 111};
        String str=new String(bytes);
        System.out.println(str);
    }
}
